package com.mst.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class StudentAspect {
    @Pointcut("execution(int com.mst.service.*.add*(*))")
    public void pointCut() {
    }

    @Around("pointCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        Object result = null;
        try {
            result = joinPoint.proceed();
            Object[] args = joinPoint.getArgs();
            System.out.println("执行了" + joinPoint.getSignature().getName() + "操作,执行的类是:" + joinPoint.getTarget() + ",执行的参数是:" + args[0]);
        } catch (Throwable e) {
            e.printStackTrace();
        }
        return result;
    }
}
